// routes/hello-hapi.js
const {jwtHeaderDefine} = require('../utils/router-helper');
module.exports = [
    {
      method: 'GET',
      path: '/',
      handler: (request, reply) => {
        // console.log(request.auth.credentials);//{ userId: 1 }
        reply('hello hapi');
      },
      config: {
        tags: ['api', 'tests'],
        description: '测试hello-hapi是否通畅',
        validate: {
          ...jwtHeaderDefine
        }
      },
    },
    {
      method: 'GET',
      path: '/hapi',
      handler: (request, reply) => {
        // console.log(request.auth.credentials);//{ userId: 1 }
        reply('test nginx proxy');
      },
      config: {
        tags: ['api', 'tests'],
        auth: false,
        description: '测试nginx代理',
        cors: {//设置允许跨域   调试web端使用
          origin: ['*'],
          additionalHeaders: ['cache-control', 'x-requested-with']
        }
      },
    },
  ];